/**
@author		Jong Min, Lee
@date		  01/15/2014
@breif		Monitor class 

copyright(c) Tae Young Soft. All right reserved. 2014
*/
#pragma once

#include "multimon.h"
#include "Taurus_Util/Macros.h"
#include "Taurus_Util/TUTypes.h"
#include "Taurus_Common/TCDefine.h"

/**
@brief		class that represents monitor
*/
class TAURUS_COMMON_EXPORT CMonitor
{
private:
  DISALLOW_COPY_AND_ASSIGN(CMonitor);

public:
  /**
  @brief		default constructor
  */
  CMonitor(void);

  /**
  @brief		destructor
  */
  ~CMonitor(void);

  /**
  @brief		initialize monitor
  @param		hMonitor hanlde to display monitor
  @param    strMonitorInfo information about display monitor
  @param    strDeviceInfo  information about the initialization and environment of display monitor
  @param    enumResType    resolution type of display monitor
  @return	  ERROR_SUCCESS upon success, an error codeo otherwise	
  */
  DWORD init(HMONITOR                    hMonitor,
             const MONITORINFOEX&        stMonitorInfo,
             const DEVMODE&              stDeviceInfo,
             const MonitorResolutionType enumResType);

 /**
  @brief		get rect specifying the monitor rectangle, expressed in virtual-screen coordinates.
            Note that if the monitor is not the primary display monitor, some of ractangle's coordinates may be nagative values.
  @return		pointer to monitor rectangle
  */
  inline const RECT* getRect(void) const
  {
    return &(m_stMonitorInfo.rcMonitor);
  }

  /**
  @brief		get rect specifying the work area rectangle of the monitor, expressed in virtual-screen coordinates.
  @return		pointer to work area rectangle of the monitor
  */
  inline const RECT* getWorkRect(void) const
  {
    return &(m_stMonitorInfo.rcWork);
  }

  /**
  @brief		set monitor work area
  @param		pRECT pointor to area
  @return		ERROR_SUCCESS upon success, an error code otherwise
  */
  void setWorkRect(const RECT& rcRect);

  /**
  @brief		whether this is primary monitor
  @return		true if the monitor is primary, false if not
  */
  inline BOOL isPrimaryMonitor(void) const
  {
    return (m_stMonitorInfo.dwFlags & MONITORINFOF_PRIMARY) == MONITORINFOF_PRIMARY;
  }

 /**
  @brief		get resolution type
  @return		resolution type
  */
  inline MonitorResolutionType getResolutionType(void) const
  {
    return m_enumResType;
  }

private:
  //hanlde to display monitor
  HMONITOR    m_hMonitor;

  //information about display monitor
  MONITORINFOEX m_stMonitorInfo;

  //information about the initialization and environment of display monitor
  DEVMODE m_stDeviceInfo;

  //monitor resolution type
  MonitorResolutionType m_enumResType;
};
